package com.spatio.serving.basic.service.template.mysql.Result;

import com.spatio.serving.basic.service.template.common.vo.ChatMessageVo;

public class Result<T> {
    private int code;  // 状态码
    private String message;  // 提示信息
    private T data;  // 返回的数据

    // 构造函数
    public Result() {}

    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 静态方法用于快速创建成功和失败的结果
    public static <T> Result<T> success(T data ) {

        return new Result<>(200, "Success", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(200, message, data);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(500, message, null);
    }

    public static <T> Result<T> error(T data ) {

        return new Result<>(500, "failed", data);
    }
    public static <T> Result<T> error(Integer code , String message ,T data) {
        return new Result<>(code, message, data);
    }

    // Getter 和 Setter 方法
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}

